﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Relayresult.aspx.cs" Inherits="RaceList.activity.relay.Relayresult" %>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>随便走</title>
        <meta name="keywords" content="">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no;" />
        <meta http-equiv="cache-control" content="no-cache">
        <link href="style/layout.css" rel="stylesheet" />
    </head>
    <body>
        <% if (Request.IsLocal)
           { %>
            <%= JsonConvert.SerializeObject(SessionHelp.CycleId) %>
            <%= Request.Url.ToString() %>
            <%= JsonConvert.SerializeObject(SessionHelp.UserData) %>
        <% } %>

        <% //定义三个跳转的地址
           string resultUrl = "Relayresult.aspx?" + Parameters.relay + "=" + Relay.Id;
           string paiHangBangUrl = "Relayresult.aspx?" + Parameters.relay + "=";

           string indexUrl = "Relayindex.aspx?" + Parameters.cycle + "=" + Relay.CycleId;
           string chongxingameUrl = "Relaygame.aspx?" + Parameters.cycle + "=" + Relay.CycleId + "&" + Parameters.relay + "=" + Parameters.first;
           string bangbanggameUrl = "Relaygame.aspx?" + Parameters.relay + "=" + Relay.Id;
        %>
        <section id="web_wrap">
            <!-- 页面框架 -->
            <div class="container">
                <div class="bg_box">
                    <a href="Relayrule.aspx" class="rule">游戏规则</a>
                    <div class="game_user">
                        <% foreach (Help item in Chengji.Helps)
                           {
                               int index = Chengji.Helps.IndexOf(item) + 1; %>
                            <div class="game_user_box user<%= index %>">
                                <img src="<%= string.IsNullOrEmpty(item.HeadUrl) ? "images/user.jpg" : item.HeadUrl %>" alt="微信头像">
                                <p><%= item.Score %>m</p>
                            </div>
                        <% } %>

                        <% int num = Chengji.Helps.Count + 1; %>
                        <% for (int i = num; i <= ActivityConfig.RelayTotalPerson; i++)
                           { %>
                            <div class="game_user_box user<%= i %>">
                                <img src="images/user1.jpg" alt="">
                            </div>
                        <% } %>
                    </div>

                    <div class="game_info">
                        <% if (ActivityStatus == ActivityStatus.WeiKaishi)
                           { %>
                            <p class="event_over">本活动未开始，敬请期待^_^</p>
                        <% } %>
                        <%
                           else if (ActivityStatus == ActivityStatus.Jiesu)
                           { %>
                            <p class="event_over">本活动已结束，感谢您的参与^_^</p>
                        <% } %>
                        <%
                           else
                           { %>
                            <p><%= Chengji.NickName.SubHtml(8) %>已经跑了<%= Chengji.SumScore %>m</p>
                            <p>离apple watch 还差<em><%= ActivityConfig.RelayMaxScore - Chengji.SumScore %>m</em></p>
                        <% } %>


                        <% if (Relay.WeixinUserId == SessionHelp.UserData.WeixinUserId)
                           {
                               //判断活动发起者和当前登录是否是同一个人 %>
                            <% if (Chengji.IsGameOver)
                               {
                            %>
                                <% if (!Chengji.HasAward)
                                   {
                                       //如果没有兑奖%>
                                    <p class="event_over">
                                        恭喜你获得10元手机话费<br>
                                        兑奖码：<%= Chengji.WinCode %>
                                    </p>
                                    <a href="http://a.app.qq.com/o/simple.jsp?pkgname=cn.gogocity.suibian" class="again">立即下载随便走APP兑奖</a>
                                    <h5><a href="<%= chongxingameUrl %>"><i></i>再玩一次</a></h5>
                                <% } %>
                                <%
                                   else if (Chengji.IsTop10)
                                   {
                                       //判断是否前10名%>
                                    <% if (ActivityStatus == ActivityStatus.Jiesu)
                                       { %>                                
                                        <a class="again">请等待工作人员联系发放奖品</a>
                                    <% }
                                       else
                                       { %>
                                        <a href="Relayrule.aspx" class="again">查看领奖规则</a>
                                    <% } %>
                                    <h5><a href="<%= chongxingameUrl %>"><i></i>再玩一次</a></h5>
                                <% } %>
                                <%
                                   else
                                   { %>
                                    <a href="<%= chongxingameUrl %>" class="again">再玩一次</a>
                                <% } %>
                            <% }
                               else
                               { %>
                                <p class="friend">邀请满4位好友帮跑就能获得幸运奖品哦！（每天限前100名兑奖者）</p>
                                <a href="javascript:;" id="yaoqing" class="again">邀请朋友帮帮跑</a>
                                <h5><a href="<%= chongxingameUrl %>"><i></i>再玩一次</a></h5>
                            <% } %>
                        <% }
                           else
                           {
                               //非本人点击%>
                            <% if (LoginUserData.CanHelp)
                               { %>
                                <a href="<%= bangbanggameUrl %>" class="playtoo btnMove">帮帮跑</a>
                                <a href="<%= indexUrl %>" class="playtoo">我也要玩</a>
                            <% } %>
                            <%
                               else if (LoginUserData.IsPlay)
                               {
                                   //可以跳转到最好成绩的那一条记录%>
                                <a href="javascript:;" class="again" id="seeBest">查看我自己的乐园</a>
                            <% }
                               else
                               {
                                   //如果没有参与过游戏 %>
                                <a href="<%= indexUrl %>" class="again">我也要赢apple watch</a>
                            <% } %>
                        <% } %>
                    </div>
                    <form id="form1" runat="server">
                        <asp:Button runat="server" ID="BestScore" Style="display: none" OnClick="BestScore_Click" />
                    </form>


                    <div class="ranking">
                        <div class="ranking_title">
                            <% if (ActivityStatus == ActivityStatus.Jiesu)
                               { %>
                                总成绩榜
                            <% }
                               else
                               { %>
                                排 行 榜
                            <% } %>
                        </div>
                        <% if (Chengji.Mingci != 0)
                           { %>
                            <h4><%= Chengji.NickName.SubHtml(6) %>位于第<em><%= Chengji.Mingci %></em>位，打败了全国<em><%= Chengji.Baifenbi == 0.0 ? "大多数" : Chengji.Baifenbi + "%" %></em>玩家</h4>
                        <% }
                           else
                           { %>
                            <h4>只有在分享给朋友完成比赛后才有排名哦</h4>
                        <% } %>
                        <div class="namebox">
                            <!-- nameline -->
                            <%
                                num = Paihangs.Count();
                                foreach (Paihang item in Paihangs)
                                {
                                    int index = Paihangs.IndexOf(item) + 1;
                                    int classNum = 0;
                                    if (index > 3)
                                        classNum = 0;
                                    else
                                        classNum = index;
                            %>

                                <div class="nameline" <%= index - 1 == 0 ? "style='margin-top: 60px;'" : "" %>>
                                    <a href="<%= paiHangBangUrl + item.RelayId %>">
                                        <div class="num<%= classNum == 0 ? "" : classNum.ToString() %>"><%= index %></div>
                                        <img src="<%= string.IsNullOrEmpty(item.Headimgurl) ? "images/user.jpg" : item.Headimgurl %>" alt="微信头像">
                                        <div class="name"><%= item.Nickname.SubHtml(8) %></div>
                                        <div class="km"><%= item.SumScore %>m</div>
                                        <div class="clear"></div>
                                    </a>
                                </div>

                            <% } %>
                            <% if (num == 0)
                               { %>
                                <div class="nameline" style="margin-top: 60px;">
                                    <div class="name">好机会哦,快来抢头条!</div>
                                </div>
                            <% } %>
                        </div>
                    </div>

                    <div class="clear"></div>

                    <div class="noranking">
                        <h3>没上排行榜？来试试手气</h3>
                        <p>现在试用随便走APP<em>足迹</em>功能，留下暑期游玩的足迹，并在其附上“暑假”两个字，就有机会赢取更多奖品！</p>
                        <span>(详情请查看随便走APP内活动页面）</span>
                    </div>

                    <div class="footer">
                        <div class="footer_text">
                            <p>Copyright © 2014-2015</p>
                            <p>深圳感知网络有限公司 版权所有</p>
                        </div>
                    </div>
                </div>


                <div class="suibianDL">
                    <div class="suibianDL_left">
                        <img src="images/logo.jpg" alt="">
                        <h5>随便走</h5>
                        <p>最后一公里生活神器</p>

                        <div class="clear"></div>
                    </div>
                    <div class="suibianDL_right">
                        <a href="http://a.app.qq.com/o/simple.jsp?pkgname=cn.gogocity.suibian">立刻下载</a>
                    </div>

                    <div class="clear"></div>
                </div>
            </div>
            <!-- 分享 -->
            <div class="shareto" style="display: none">
                <p>考验人品的时候到了~~~</p>
                <p>分享到好友、群和朋友圈</p>
                <p>帮跑赢取<em>apple watch</em>吧！</p>
            </div>
            <div class="overlay" style="display: none"></div>
            <!-- 分享end -->

        </section>
    </body>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
        $(function() {
            //1.config
            wx.config({
                debug: false,
                appId: "<%= WxConfig.appid %>",
                timestamp: "<%= WxConfig.timestamp %>",
                nonceStr: "<%= WxConfig.noncestr %>",
                signature: "<%= WxConfig.signature %>",
                jsApiList: [
                    'checkJsApi',
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo'
                ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
            });
            //2.ready
            wx.ready(function() {
                //检查客户端是否支持某个js接口
                wx.checkJsApi({
                    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo'], // 需要检测的JS接口列表，所有JS接口列表见附录2,
                    success: function(res) {
                        // 以键值对的形式返回，可用的api值true，不可用为false
                        // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
                    }
                });
                wx.showOptionMenu();
                wx.hideMenuItems({
                    menuList: [
                        "menuItem:editTag",
                        "menuItem:delete",
                        "menuItem:copyUrl",
                        "menuItem:originPage",
                        "menuItem:readMode",
                        "menuItem:openWithQQBrowser",
                        "menuItem:openWithSafari",
                        "menuItem:share:email",
                        "menuItem:share:brand"
                    ]
                });
                //分享给朋友
                wx.onMenuShareAppMessage({
                    title: ' 听说一起跑能赢高bigger的Apple Watch耶！',
                    desc: '快来玩游戏吧，我已经跑了<%= Chengji.SumScore %>m，看你能不能跑过我~',
                    link: "<%= ("http://" + Request.Url.Authority + "/activity/relay/" + resultUrl).AddTimeStamp() %>",
                    imgUrl: "<%= "http://" + Request.Url.Authority + "/activity/relay/images/logo.jpg" %>",
                    trigger: function(res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
                    },
                    success: function(res) {
                    },
                    cancel: function(res) {
                    },
                    fail: function(res) {
                        alert(JSON.stringify(res));
                    }
                });
                wx.onMenuShareTimeline({
                    title: '游戏还差<%= ActivityConfig.RelayMaxScore - Chengji.SumScore %>米就能拿到高bigger的Apple Watch啦，快来跟我一起跑吧^_^',
                    link: "<%= ("http://" + Request.Url.Authority + "/activity/relay/" + resultUrl).AddTimeStamp() %>",
                    imgUrl: "<%= "http://" + Request.Url.Authority + "/activity/relay/images/logo.jpg" %>",
                    trigger: function(res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
                    },
                    success: function(res) {
                    },
                    cancel: function(res) {
                    },
                    fail: function(res) {
                        alert(JSON.stringify(res));
                    }
                });
                wx.onMenuShareQQ({
                    title: '游戏还差XX米就能拿到高bigger的Apple Watch啦，快来跟我一起跑吧^_^',
                    desc: '快来玩游戏吧，我已经跑了<%= Chengji.SumScore %>m，看你能不能跑过我~',
                    link: "<%= ("http://" + Request.Url.Authority + "/activity/relay/" + resultUrl).AddTimeStamp() %>",
                    imgUrl: "<%= "http://" + Request.Url.Authority + "/activity/relay/images/logo.jpg" %>",
                    trigger: function(res) {
                    },
                    complete: function(res) {
                    },
                    success: function(res) {
                    },
                    cancel: function(res) {

                    },
                    fail: function(res) {
                        alert(JSON.stringify(res));
                    }
                });
                wx.onMenuShareWeibo({
                    title: '游戏还差XX米就能拿到高bigger的Apple Watch啦，快来跟我一起跑吧^_^',
                    desc: '快来玩游戏吧，我已经跑了<%= Chengji.SumScore %>m，看你能不能跑过我~',
                    link: "<%= ("http://" + Request.Url.Authority + "/activity/relay/" + resultUrl).AddTimeStamp() %>",
                    imgUrl: "<%= "http://" + Request.Url.Authority + "/activity/relay/images/logo.jpg" %>",
                    trigger: function(res) {
                    },
                    complete: function(res) {
                    },
                    success: function(res) {
                    },
                    cancel: function(res) {
                    },
                    fail: function(res) {
                        alert(JSON.stringify(res));
                    }
                });

            });
            //3.error
            wx.error(function(res) {
                win_alert(JSON.stringify(res));
            });
        });
        $('#seeBest').click(function() {
            $('#BestScore').click();
        });
        $('#yaoqing').click(function() {
            $('.shareto').show();
            $('.overlay').show();
        });
        $('.overlay').click(function() {
            $('.shareto').hide();
            $('.overlay').hide();
        });
    </script>
</html>
<script src="js/main.js"></script>